#import <misckit/MiscSliderField.h>

#import "TreeInspector.h"
#import "Tree.h"

@implementation TreeInspector

- init
{  
   	[super init];
	view = nil;	
	return self;
}
   
- (BOOL)wantsButtons 
{ 
	return NO; 
}

- (BOOL)doesHandleSelection
{
	char buf[MAXPATHLEN + 1];
    id bundle;
	
	if([self selectionCount] == 1 && 
		[[self selection] isMemberOf:[Tree class]] && ![[self selection] parent]){
		if(!view){
		 	bundle = [NXBundle mainBundle];
    		[bundle getPath:buf forResource:"TreeInspector" ofType:"nib"];
   			[NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
		}
		return YES;
	}
	return NO;
}

- ok:sender
{
	[(NXColorWell *)shadowColor deactivate];
	return [super ok:sender];
}

- revert:sender
{
	id tree;
	
	[super revert:sender];
	tree = [self selection];
	[shadowColor setColor:[tree shadowColor]];
	[shadow setState:[tree shadow]];
	[border setFloatValue:[tree border]];
	[parentDistance setFloatValue:[tree parentDistance]];
	[linkKind setState:[tree linkKind]];
	[biegFactor setFloatValue:[tree biegFactor]];
	[biegFactor setEnabled:[tree linkKind]];
	return self;
}

- changeShadowColor:sender
{
	[[self selection] setShadowColor:[sender color]];
	return self;
}

- changeShadow:sender
{
	[[self selection] setShadow:[sender state]];
	return self;
}

- changeParentDistance:sender
{
	[[self selection] setParentDistance:[sender floatValue]];
	return self;
}

- changeBorder:sender
{
	[[self selection] setBorder:[sender floatValue]];
	return self;
}

- changeLinkKind:sender
{
	[[self selection] setLinkKind:[sender state]];
	[biegFactor setEnabled:[sender state]];
	return self;
}
 
- changeBiegFactor:sender
{
	[[self selection] setBiegFactor:[sender floatValue]];
	return self;
}
  
@end
